package com.znsd.exam.controllor;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.znsd.exam.entity.Exam;
import com.znsd.exam.service.ExamService;
import com.znsd.stu.entity.Staff;
import com.znsd.stu.service.StaffService;

@Controller
public class ExamControll {
	
	@Autowired
	private ExamService examService;
	
	@Autowired
	private StaffService staffService;
	
	@RequestMapping(value = "/login" ,method = RequestMethod.GET)
	public String login() {
		System.out.println("123");
		List<Exam> list = examService.queryAll();
		for (Exam exam : list) {
			System.out.println(exam);
		}
		return "login";
	}
	
	@ResponseBody
	@RequestMapping(value = "/loginpost" ,method = RequestMethod.POST)
	public String loginpost(Staff staff) {
		System.out.println(staff.getEmail());
		Staff sta = staffService.queryLogin(staff);
		System.out.println(sta);
		if(sta!=null) {
			System.out.println(1299999999);
			return "indexExam";
		}
		return "login";
		
	}
	
	@RequestMapping(value = "/indexExam" ,method = RequestMethod.GET)
	public String indexExam() {
		return "indexExam";
	}
}
